package com.fanxuankai.boot.mqbroker.producer.autoconfigure;

import com.fanxuankai.boot.mqbroker.producer.EventPublisher;
import com.fanxuankai.boot.mqbroker.producer.MsgSendService;
import com.fanxuankai.boot.mqbroker.producer.MsgSendServiceImpl;
import com.fanxuankai.boot.mqbroker.producer.ProducerTaskConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author fanxuankai
 */
@EnableConfigurationProperties(MqBrokerProducerProperties.class)
@ConditionalOnProperty(name = MqBrokerProducerProperties.ENABLED, matchIfMissing = true)
public class MqBrokerProducerAutoConfiguration {
    @Bean
    public EventPublisher<?> eventPublisher() {
        return new EventPublisher<>();
    }

    @Bean
    public MsgSendService msgSendService() {
        return new MsgSendServiceImpl();
    }

    @Bean
    public ProducerTaskConfigurer producerTaskConfigurer() {
        return new ProducerTaskConfigurer();
    }
}
